<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<title></title>
<!--	<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/element-ui@2.15.13/lib/theme-chalk/index.min.css" />-->
	<script src="https://cdn.jsdelivr.net/npm/jquery@2.2.4/dist/jquery.min.js"></script>
	<script src="https://cdn.jsdelivr.net/npm/vue@2.7.14/dist/vue.min.js"></script>
<!--	<script src="https://cdn.jsdelivr.net/npm/element-ui@2.15.13/lib/index.min.js"></script>-->
	<link rel="stylesheet" th:href="@{/static/bootstrap.min.css}" />
</head>
<body>
<div class="container-fluid" id="app" style="margin-top: 120px;margin-bottom: 100px">

	<div class="container">

		<div class="row">
			<a href="/login.html">已有账号?立即去登录</a>
			<div class="col-md-4 col-md-offset-4" style="border: 1px solid #cccccc ;border-radius: 5px;margin-top: 10px">
				<form >
					<div class="form-group">
						<label for="account" >用户名:</label>
						<input type="text" v-model="registerFrom.sellerName" name="username" class="form-control" id="account" placeholder="请输入用户名">
					</div>
					<div class="form-group">
						<label for="password">密码</label>
						<input type="password" v-model="registerFrom.sellerPassword" name="password" class="form-control" id="password" placeholder="请输入密码">
					</div>
					<div class="form-group">
						<label for="repass">确认密码:</label>
						<input type="password" v-model="registerFrom.rePassword" name="repass" class="form-control" id="repass" placeholder="请输入确认密码">
					</div>

					<button type="submit" @click.prevent="toReg" class="btn btn-success">注册</button>
				</form>
			</div>
		</div>

	</div>

</div>

<script>

	console.log(".........register...........")

	let register = new Vue({
		el: "#app"
		,
		data: {

			registerFrom:{
				sellerName:'',
				sellerPassword:'',
				rePassword:''
			}
		}
		,
		methods: {

			toReg(){
				//1.搜集表单数据
				console.log(this.registerFrom)

				//做一些数据校验什么的.......

				//2.访问后端接口,根据访问结果做对应处理.
				// 成功: 提示并跳转到登录页
				// 失败: 提示错误信息
				$.post("/seller/register",this.registerFrom,function (data) {
					if (data=='ok'){
						//注册成功,提示并跳转到登录页
						alert("注册成功,立即前往登录页")
						location.href="/login.html"
					}else {
						//注册失败
						alert(data)
					}
				})

			}

		}
		,
		created(){

		}

	});


</script>
</body>
</html>
